﻿using MongoDB.Driver;
using MongoDB.Driver.Linq;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace LearningWorkbench
{
    public static class DbManager
    {
        readonly static string _connectionString = "mongodb://localhost";
        static MongoDatabase _database;

        public static void ConnectToDatabase(string database)
        {
            var client = new MongoClient(_connectionString);
            var server = client.GetServer();
            _database = server.GetDatabase(database);
        }

        public static MongoCollection<T> GetCollection<T>(string collection)
        {
            return _database.GetCollection<T>(collection);
        }

        public static MongoCollection GetCollection(string collection)
        {
            return _database.GetCollection(collection);
        }

        public static IEnumerable<string> ListCollections()
        {
            return _database.GetCollectionNames();
        }
    }
}
